//
//  SQStatusCell.swift
//  SwiftWeibo
//
//  Created by 苏强 on 16/12/5.
//  Copyright © 2016年 suqianghotel. All rights reserved.
//

import UIKit

class SQStatusCell: UITableViewCell {
    
    var statusViewModel : SQStatusViewModel?
    {
        didSet{
            
            avatar.sq_setImage(with: statusViewModel?.status.user?.profile_image_url,
                               placeholderImage: UIImage(named: "avatar_default_big"),
                               isCircle:true)
            
            nickname.text = statusViewModel?.status.user?.screen_name
            
            statusText.text = statusViewModel?.status.text
            
            toolBar.viewModel = statusViewModel
            
            picturesView.viewModel = statusViewModel
            
            repostStatusText?.text = statusViewModel?.repostStatusText
            
        }
    }

    /// 头像
    @IBOutlet weak var avatar: UIImageView!
    
    
    /// 认证图标
    @IBOutlet weak var authIcon: UIImageView!
    
    /// 昵称
    @IBOutlet weak var nickname: UILabel!
    
    /// 会员等级
    @IBOutlet weak var vipIcon: UIImageView!
    
    /// 时间
    @IBOutlet weak var time: UILabel!
    
    /// 来源
    @IBOutlet weak var source: UILabel!
    
    /// 操作按钮
    @IBOutlet weak var operate: UIButton!
    
    /// 微博正文
    @IBOutlet weak var statusText: UILabel!
    
    /// 微博正文
    @IBOutlet weak var picturesView: SQStatusPicturesView!
    
  
    @IBOutlet weak var repostStatusText: UILabel?
    
    /// 顶部工具栏
    @IBOutlet weak var toolBar: SQStatusCellToolBar!
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.translatesAutoresizingMaskIntoConstraints = false
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
    
        self.selectedBackgroundView = UIView()
        let bgcolor = UIColor(hex:0xEFEFEF)
        self.selectedBackgroundView?.backgroundColor = bgcolor
        
//        self.layer.drawsAsynchronously = true
//        self.layer.shouldRasterize = true
//        self.layer.rasterizationScale = UIScreen.main.scale
        
    
        
    }
    
    
    @IBAction func repostClicked(_ sender: UIButton) {
        
        sender.backgroundColor = UIColor.random
        
    }
    

    override func setSelected(_ selected: Bool, animated: Bool) {
//        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    
    
    private func setupUI()
    {
    
        
    }
    
    
    
    
}
